//
//  PTSelfLaunch.swift
//  PointTest28
//
//  Created by sc-chen on 2023/8/31.
//

import SwiftUI

struct PTSelfLaunch: View {
    
    @State private var isShowingHUD = false
    @State private var detailTxt = "不支持开发功能"
    
    var body: some View {
        ZStack {
            ScrollView {
                VStack {
                    Button {
                        showHud()
                    } label: {
                        Text("自启动程序检测")
                            .foregroundColor(.white)
                            .padding()
                            .frame(maxWidth: .infinity)
                            .background(
                                RoundedRectangle(cornerRadius: 5)
                                    .fill(Color.blue)
                            )
                    }
                    .buttonStyle(.borderless)
                    .padding(.top,20)
                    Spacer()
                }
            }
            PTProgressHud(isPresented: $isShowingHUD, text: $detailTxt)
        }.onAppear(){
            showHud()
        }
    }
    
    private func showHud() {
        isShowingHUD = true
        DispatchQueue.main.asyncAfter(deadline: .now()+2){
            isShowingHUD = false
        }
    }
}

struct PTSelfLaunch_Previews: PreviewProvider {
    static var previews: some View {
        PTSelfLaunch()
    }
}
